package com.hjm.project.channel.picturesInfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.channel.picturesInfo.domain.AgentPicturesInfo;
import com.hjm.project.channel.picturesInfo.service.IAgentPicturesInfoService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 代理商图片信息Controller
 * 
 * @author maker-platform
 * @date 2025-05-27
 */
@Controller
@RequestMapping("/channel/picturesInfo")
public class AgentPicturesInfoController extends BaseController {
    private String prefix = "channel/picturesInfo";

    @Resource
    private IAgentPicturesInfoService agentPicturesInfoService;

    @RequiresPermissions("channel:picturesInfo:view")
    @GetMapping()
    public String picturesInfo() {
        return prefix + "/picturesInfo";
    }

    /**
     * 查询代理商图片信息列表
     */
    @RequiresPermissions("channel:picturesInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentPicturesInfo agentPicturesInfo) {
        startPage();
        List<AgentPicturesInfo> list = agentPicturesInfoService.selectAgentPicturesInfoList(agentPicturesInfo);
        return getDataTable(list);
    }

    /**
     * 导出代理商图片信息列表
     */
    @RequiresPermissions("channel:picturesInfo:export")
    @Log(title = "代理商图片信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentPicturesInfo agentPicturesInfo) {
        List<AgentPicturesInfo> list = agentPicturesInfoService.selectAgentPicturesInfoList(agentPicturesInfo);
        ExcelUtil<AgentPicturesInfo> util = new ExcelUtil<AgentPicturesInfo>(AgentPicturesInfo.class);
        return util.exportExcel(list, "picturesInfo");
    }

    /**
     * 新增代理商图片信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存代理商图片信息
     */
    @RequiresPermissions("channel:picturesInfo:add")
    @Log(title = "代理商图片信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentPicturesInfo agentPicturesInfo) {
        return toAjax(agentPicturesInfoService.insertAgentPicturesInfo(agentPicturesInfo));
    }

    /**
     * 修改代理商图片信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        AgentPicturesInfo agentPicturesInfo = agentPicturesInfoService.selectAgentPicturesInfoById(id);
        mmap.put("agentPicturesInfo", agentPicturesInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存代理商图片信息
     */
    @RequiresPermissions("channel:picturesInfo:edit")
    @Log(title = "代理商图片信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentPicturesInfo agentPicturesInfo) {
        return toAjax(agentPicturesInfoService.updateAgentPicturesInfo(agentPicturesInfo));
    }

    /**
     * 删除代理商图片信息
     */
    @RequiresPermissions("channel:picturesInfo:remove")
    @Log(title = "代理商图片信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(agentPicturesInfoService.deleteAgentPicturesInfoByIds(ids));
    }
}
